/*显示*/
function modalShow(pop){
	if($('#'+pop+':visible')[0]){
		return;
	}
	if(!$('.modal-backdrop')[0]){
		$('body').append("<div class='modal-backdrop'></div>");
		modalLayout();
	}
	$('#'+pop).show();
	modalCenter(pop);

	$('#'+pop).find('.close').on('click',function(){
		modalHide(pop)
	});

	var h = $('#'+pop).find('.modal-bd').height();
	if(h>300){
		$('#'+pop).find('.modal-bd').css('height',300);
	}
}

function modalHide(pop){
	$('#'+pop).hide();
	$('.modal-backdrop').remove();
}

//遮罩满屏
function modalLayout(){
	$('.modal-backdrop').css({
		'width':$('body').width(),
		'height':$('body').height()
	});
}

//窗体居中
function modalCenter(pop){
	var t = isIE6 ? ($(window).height()/ 2) + $(window).scrollTop() + "px" : ($(window).height()/ 2) + "px";
	var mt = $('.modal').height()>427 ? 427 : $('.modal').height();
	$('#'+pop).css({'top':t,'margin-top':-mt/2});
}

//改变窗体重新调整位置
window.onresize = function() {
  modalLayout();
  modalCenter();
}

window.onscroll = function() {
    modalLayout();
    modalCenter();
}

document.onkeyup = function(event) {
  var evt = window.event || event;
  var code = evt.keyCode ? evt.keyCode : evt.which;
  if(code == 27) {
    popRemove(pop);
  }
}